﻿using System;
using System.Collections.Generic;
using System.Text;

namespace MingYuanYun.Utility
{
    public static class ObjectExtensions
    {
        public static Dictionary<string, string> MembersToDictionary<T>(this T obj)
        {
            Dictionary<string, string> dict = new Dictionary<string, string>();
            var properties = obj.GetType().GetProperties();

            foreach (var property in properties)
            {
                //var name = $"{obj.GetType().Name}:{property.Name}";
                var name = $"{property.Name}";
                var val = property.GetValue(obj);
                dict.Add(name, val == null ? "":val.ToString());
            }

            return dict;
        }
    }
}
